<template>
	<view class="user_order">
		<view class="main">
			<view class="item" v-for="(item,index) in list" :key="index" @click="handleClick(item)">
				<view class="img">
					<image :src="item.img" mode="widthFix"></image>
				</view>
				<text class="text">{{item.text}}</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { gethexiao } from '@/request/api.js'
	import { toast,useRouter } from '@/request/utils.js'
	export default {
		data() {
			return {
				list: [
					{
						img: "https://hetp.hephp.cn/static/images/order_sm.png",
						text: '扫码验券',
						path: '',
						type: 1,
					},
					{
						img: "https://hetp.hephp.cn/static/images/order_hx.png",
						text: '订单核销',
						path: '/pagesA/orderHX/orderHX',
					},
					{
						img: "https://hetp.hephp.cn/static/images/order_gl.png",
						text: '订单管理',
						path: '/pagesA/order/order',
					},
					{
						img: "https://hetp.hephp.cn/static/images/order_zk.png",
						text: '客资中心',
						path: '/pagesA/kzCenter/kzCenter',
					},
				]
			};
		},
		methods: {
			handleClick(item){
				if(item.type){
					// this.scanQrcode();
					uni.scanCode({
					  onlyFromCamera: false,
					  success (res) {
						console.log("扫描内容",res.result)
						console.log("rawData",res.rawData)
						that.getOrders(res.result)
					  }
					})
				}else{
					this.goToPage(item.path);
				}
				
			},
			//核销处理
			async getOrders(nums) {
				console.log('测试传输',nums)
			  let res = await gethexiao({nums:nums});
			  if(res.code==200){
				  this.goToNoLoginPage('/pagesA/orderDetailHX/orderDetailHX?id='+res.data.couponId,'navigateTo');
			  }else{
				  toast(res.message)
			  }
			},
		}
	}
</script>

<style lang="scss" scoped>
.main {
	display: flex;
	justify-content: space-between;
	align-items: center;
	.item {
		width: 20%;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		.img {
			width: 70rpx;
			height: 70rpx;
			margin-bottom: 15rpx;
		}
		.text {
			font-size: 25rpx;
		}
	}
}
</style>
